#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
const int MAXN=1e9+7;
const int SIZE=200005;
int t;
int n,a[SIZE];
int lx,ans;
signed main(){
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    while(t--){
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        for(int i=1;i<=n;i++){
            if(a[i]==a[i-1]){
                lx++;
            }
            else{
                ans+=a[i-1]*lx;
                lx=0;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
